package com.hdoit.kylin.logical.user.dao.impl;


import java.util.List;

import org.springframework.stereotype.Component;

import com.hdoit.kylin.logical.user.dao.IStudentDao;
import com.hdoit.kylin.logical.user.model.Student;
import com.tennetcn.common.dao.base.IFinderExpression;
import com.tennetcn.common.dao.base.impl.SuperDao;
import com.tennetcn.common.message.PagerModel;
import com.tennetcn.common.message.SearchModel;
import com.tennetcn.common.utils.FinderExpressionFactory;
/**
* @author luozhicheng
* @email
* @createtime 2017年07月18日 20:46:36
* @comment
*/
@Component
public class StudentDaoImpl extends SuperDao<Student> implements IStudentDao{
	@Override
	public List<Student> queryListByGroupId(SearchModel search,PagerModel pagerModel,String groupId) {
		IFinderExpression finderExpression=FinderExpressionFactory.createExpression();
		finderExpression.addBody("select * from ",Student.class)
						.resolveSearchModel(search)
						.andWhere("groupId=#{groupId}")
						.setParam("groupId", groupId);
		return queryList(finderExpression,pagerModel);
	}

	@Override
	public int queryCountByGroupId(SearchModel search, String groupId) {
		IFinderExpression finderExpression=FinderExpressionFactory.createExpression();
		finderExpression.addBody("select count(1) from ",Student.class)
						.resolveSearchModel(search)
						.andWhere("groupId=#{groupId}")
						.setParam("groupId", groupId);
		return queryCount(finderExpression);
	}

	@Override
	public List<Student> queryListByGroupId(String groupId) {
		IFinderExpression finderExpression=FinderExpressionFactory.createExpression();
		finderExpression.addBody("select * from ",Student.class)
						.andWhere("groupId=#{groupId}")
						.setParam("groupId", groupId);
		return queryList(finderExpression);
	}
	
	@Override
	public List<Student> queryListByGraduate(int graduateMark){
		IFinderExpression finderExpression = FinderExpressionFactory.createExpression();
		finderExpression.addBody("select * form", Student.class)
						.andWhere("graduateMark=#{graduateMark}")
						.setParam("graduateMark", graduateMark);
		return queryList(finderExpression);
	}
}